<div class="box box-info">
    <div class="box-header with-border">
        <h3 class="box-title"></h3>
        <div class="box-tools">
            <div class="btn-group pull-right" style="margin-right: 10px">
                @if($order->status == 0)
                    <a href="{{ route('admin.orders.index') }}" class="btn btn-sm btn-default"><i class="fa fa-list"></i> 列表</a>
                @elseif($order->status == 3)
                    <a href="{{ route('admin.orders3.index') }}" class="btn btn-sm btn-default"><i class="fa fa-list"></i> 列表</a>
                @elseif($order->status ==-1)
                    <a href="{{ route('admin.orders4.index') }}" class="btn btn-sm btn-default"><i class="fa fa-list"></i> 列表</a>
                @else
                    <a href="{{ route('admin.orders2.index') }}" class="btn btn-sm btn-default"><i class="fa fa-list"></i> 列表</a>
                @endif
            </div>
        </div>
    </div>
    <div class="box-body">
        <table class="table table-bordered">
            <tbody>
            <tr>
                <td>订单流水号</td>
                <td colspan="3">{{ $order->no }}</td>
            </tr>
            <tr>
                <td>状态</td>
                <td colspan="3">{{ \App\Models\Order::$statusMap[$order->status] }}</td>
            </tr>
            <tr class="active">
                <td colspan="4"></td>
            </tr>

            <tr class="warning">
                <td colspan="4">用户下单信息</td>
            </tr>
            <tr>
                <td>用户昵称</td>
                <td colspan="3">{{ $order->user->wechat_nickname }}</td>
            </tr>
            <tr>
                <td>用户绑定手机号</td>
                <td colspan="3">{{ $order->user->telephone }}</td>
            </tr>
            <tr>
                <td>会员剩余天数</td>
                <td colspan="3">{{ $order->vip_days }}</td>
            </tr>

            <tr>
                <td>下单时间</td>
                <td colspan="3">{{ $order->created_at->format('Y-m-d H:i:s') }}</td>
            </tr>
            <tr>
                <td rowspan="{{ $order->items->count() + 1 }}">借阅的书</td>
                <td>图书封面</td>
                <td>图书名称</td>
            </tr>
            @foreach($order->items as $item)
                <tr>
                    <td>
                        <img src="{{ config('app.qiniu_image_domain').DIRECTORY_SEPARATOR.$item->book->image }}" alt="..." class="img-rounded" width="80px;" height="110px;">
                    </td>
                    <td>{{ $item->book->title }}  &nbsp;&nbsp;&nbsp;({{ $item->book->parent_catgeory->title }} -- {{ $item->book->category->title }} -- {{ $item->book->book_publish_info->isbn }})</td>
                </tr>
            @endforeach
            <tr class="active">
                <td colspan="4"></td>
            </tr>

            @if($order->status === 0)
                <tr>
                    <td colspan="4">
                        <form action="{{ route('admin.orders.ship', [$order->id]) }}" method="post" class="form-inline">
                            <!-- 别忘了 csrf token 字段 -->
                            {{--<input type="hidden" name="_token" value="{{ csrf_token() }}">--}}
                            {{ csrf_field() }}
                            <div class="form-group {{ $errors->has('express_company') ? 'has-error' : '' }}">
                                <label for="express_company" class="control-label">物流公司</label>
                                <select class="form-control" id="express_company" name="express_company">
                                    @foreach(\App\Models\Express::all() as $express)
                                        <option value="{{ $express->id }}">{{ $express->name }}</option>
                                    @endforeach
                                </select>

                                @if($errors->has('express_company'))
                                    @foreach($errors->get('express_company') as $msg)
                                        <span class="help-block">{{ $msg }}</span>
                                    @endforeach
                                @endif
                            </div>
                            <div class="form-group {{ $errors->has('express_no') ? 'has-error' : '' }}">
                                <label for="express_no" class="control-label">物流单号</label>
                                <input type="text" id="express_no" name="express_no" value="" class="form-control" placeholder="输入物流单号">
                                @if($errors->has('express_no'))
                                    @foreach($errors->get('express_no') as $msg)
                                        <span class="help-block">{{ $msg }}</span>
                                    @endforeach
                                @endif
                            </div>
                            <button type="submit" class="btn btn-success" id="ship-btn">发货</button>
                        </form>
                    </td>
                </tr>

            @elseif($order->status === 1)
                <tr class="warning">
                    <td colspan="4">平台发货信息</td>
                </tr>
                <tr>
                    <td colspan="4">
                        <form action="{{ route('admin.orders2.ship', [$order->id]) }}" method="post" class="form-inline">
                            <!-- 别忘了 csrf token 字段 -->
                            {{--<input type="hidden" name="_token" value="{{ csrf_token() }}">--}}
                            {{ csrf_field() }}
                            <div class="form-group {{ $errors->has('express_company') ? 'has-error' : '' }}">
                                <label for="express_company" class="control-label">物流公司</label>
                                <select class="form-control" id="express_company" name="express_company">
                                    @foreach(\App\Models\Express::all() as $express)
                                        <option value="{{ $express->id }}" <?php echo $express->name == $order->express_name?'selected':''; ?>>{{ $express->name }}</option>
                                    @endforeach
                                </select>

                                @if($errors->has('express_company'))
                                    @foreach($errors->get('express_company') as $msg)
                                        <span class="help-block">{{ $msg }}</span>
                                    @endforeach
                                @endif
                            </div>
                            <div class="form-group {{ $errors->has('express_no') ? 'has-error' : '' }}">
                                <label for="express_no" class="control-label">物流单号</label>
                                <input type="text" id="express_no" name="express_no" value="{{ $order->express_no }}" class="form-control" placeholder="输入物流单号">
                                @if($errors->has('express_no'))
                                    @foreach($errors->get('express_no') as $msg)
                                        <span class="help-block">{{ $msg }}</span>
                                    @endforeach
                                @endif
                            </div>
                            <button type="submit" class="btn btn-success" id="ship-btn">修改</button>
                        </form>
                    </td>
                </tr>
                <tr>
                    <td>发货时间</td>
                    <td colspan="3">{{ !empty($order->send_time)?date('Y-m-d H:i:s',$order->send_time):'' }}</td>
                </tr>
            @else
                <!-- 否则展示物流公司和物流单号 -->
                <tr class="warning">
                    <td colspan="4">平台发货信息</td>
                </tr>
                <tr>
                    <td>发货时间</td>
                    <td colspan="3">{{ !empty($order->send_time)?date('Y-m-d H:i:s',$order->send_time):'' }}</td>
                </tr>
                <tr>
                    <td>发货物流公司</td>
                    <td colspan="3">{{ $order->express_name }}</td>
                </tr>
                <tr>
                    <td>发货物流单号</td>
                    <td colspan="3">{{ $order->express_no }}</td>
                </tr>
            @endif

            <tr>
                <td>收货人</td>
                <td colspan="3">{{ $order->receive_contact_name }} ({{ $order->receive_contact_telephone }})</td>
            </tr>
            <tr>
                <td>收货地址</td>
                <td colspan="3">{{ $order->receive_province }} {{ $order->receive_city }} {{ $order->receive_area }} {{ $order->receive_address }}</td>
            </tr>
            <tr class="active">
                <td colspan="4"></td>
            </tr>

            @if($order->status === 3)
                <tr class="warning">
                    <td colspan="4">用户归还信息</td>
                </tr>
                <tr>
                    <td>归还状态</td>
                    <td colspan="3">{{ \App\Models\Order::$backStatusMap[$order->back_status] }}</td>
                </tr>
                @if($order->back_status == 2)
                    <tr>
                        <td>归还确认：</td>
                        <td colspan="3">
                            <form action="{{ route('admin.orders3.confirm', [$order->id]) }}" method="post" class="form-inline">
                                {{ csrf_field() }}
                                <button type="submit" class="btn btn-success" id="ship-btn">确认收货</button>
                            </form>
                        </td>
                    </tr>
                @endif

                <tr>
                    <td>提交预约还书时间</td>
                    <td colspan="3">{{ !empty($order->back_created_at)?date('Y-m-d H:i:s',$order->back_created_at):'' }}</td>
                </tr>
                <tr>
                    <td>预约快递取件时间</td>
                    <td colspan="3">{{ !empty($order->back_order_time)?date('Y-m-d H:i:s',$order->back_order_time):'' }}</td>
                </tr>
                <tr>
                    <td>预约取件地址信息</td>
                    <td colspan="3">
                        {{ $order->back_address_province }}{{ $order->back_address_city }}{{ $order->back_address_area }}{{ $order->back_address }}<br/>
                        {{ $order->back_contact_name }} ({{ $order->back_contact_telephone }})
                    </td>
                </tr>

                <tr>
                    <td>归还物流公司</td>
                    <td colspan="3">{{ !empty($order->back_express_name)?$order->back_express_name:'顺丰速运' }}</td>
                </tr>
                <tr>
                    <td>归还物流单号</td>
                    <td colspan="3">{{ $order->back_express_no }}</td>
                </tr>
            @endif
            <tr class="active">
                <td colspan="4"></td>
            </tr>

            @if($order->status == 0)
                <tr>
                    <td colspan="4">
                        <form action="{{ route('admin.orders.cancel', [$order->id]) }}" method="post" class="form-inline">
                            <!-- 别忘了 csrf token 字段 -->
                            {{--<input type="hidden" name="_token" value="{{ csrf_token() }}">--}}
                            {{ csrf_field() }}
                            <button type="submit" class="btn btn-danger" id="ship-btn">取消订单</button>
                        </form>
                    </td>
                </tr>
            @endif
            </tbody>
        </table>
    </div>
</div>